package com.czh.springboot04.service.serviceimpl;

import com.czh.springboot04.entity.Coursemark;
import com.czh.springboot04.mapper.CoursemarkMapper;
import com.czh.springboot04.service.CoursemarkService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CoursemarkServiceImpl implements CoursemarkService {
    @Autowired
    private CoursemarkMapper coursemarkService;
    @Override
    public int addCoursemark(Coursemark coursemark) {
        int i = coursemarkService.addCoursemark(coursemark);
        return i;
    }

    @Override
    public int deleteCoursemark(int id) {
        int i = coursemarkService.deleteCoursemark(id);
        return i;
    }

    @Override
    public int updateCoursemark(Coursemark coursemark) {
        int i = coursemarkService.updateCoursemark(coursemark);
        return i;
    }

    @Override
    public PageInfo<Coursemark> selectCoursemark(int pageNum, int pageSize, String nickName, String courseName) {
        PageHelper.startPage(pageNum,pageSize);
        List<Coursemark> coursemark = coursemarkService.selectCoursemark(nickName, courseName);
        PageInfo<Coursemark> pageInfo = new PageInfo<>(coursemark);
        return pageInfo;
    }

    @Override
    public List<Coursemark> findCoursemarkByCourseId(int id) {
       List<Coursemark> coursemark = coursemarkService.findCoursemarkByCourseId(id);
        return coursemark;
    }
}
